<?php
class ModelTotalDiscount extends Model {
	public function getTotal(&$total_data, &$total, &$taxes, $mark) {
		// echo 11;
		//if (time()<strtotime('2017-8-23 00:00:00') || time()>strtotime('2017-8-23 23:59:59')) {
        // if (time()<strtotime('2018-1-13 00:00:00') || time()>strtotime('2018-2-5 23:59:59')) {
			// $this->load->language('total/favour');discount

			$sub_total = $this->cart->getSubTotal();
			$Dnum = $this->cart->getCouponDis();
			$Dtotal = $this->cart->getCouponTotal();
			// var_dump($Dnum);

			if(!$mark){
				// echo 11;
				if($Dnum >= 15){
					$discount = -$Dtotal*0.05;
					$flog = 1;
				}
				if($Dnum >= 30){
					$discount = -$Dtotal*0.07;
					$flog = 2;
				}
				if($Dnum >= 50){
					$discount = -$Dtotal*0.1;
					$flog = 3;

				}
            }
            // var_dump($flog);
            if ($discount < 0){
            	if ($flog==1) {
            		$title = '订单立减5%(妙洁金额除外)';
            	}elseif ($flog==2) {
            		$title = '订单立减7%(妙洁金额除外)';
            	}elseif ($flog==3) {
            		$title = '订单立减10%(妙洁金额除外)';
            	}
                $total_data[] = array(
                    'code'       => 'discount',
                    'title'      => $title,
                    'value'      => $discount,
                    'sort_order' => $this->config->get('discount_sort_order')
                );
            }
            $total += $discount;
		}
	}
// }